package com.oceansoft.mobile.econsole.modules.member.service.impl;

import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import com.oceansoft.mobile.econsole.modules.member.entity.WtMember;
import com.oceansoft.mobile.econsole.modules.member.entity.WtMemberMange;
import com.oceansoft.mobile.econsole.modules.member.persistence.IWtMemberMapper;
import com.oceansoft.mobile.econsole.modules.member.service.IWtMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2016/1/31.
 */
@Service
public class WtMemberServiceImpl implements IWtMemberService {

    @Resource
    private IWtMemberMapper wtMemberMapper;

    @Override
    public WtMember getWtMemberByUserGuid(String guid) {

        return wtMemberMapper.getWtMemberByUserGuid(guid);
    }

    @Override
    public WtMember getWtMemberByOpenid(String openId){
        return wtMemberMapper.getWtMemberByOpenid(openId);
    }

    @Override
    public WtMember getInfoByUserName(String userName){
        return wtMemberMapper.getInfoByUserName(userName);
    }

    @Override
    public int loadUserByTelAndPwd(String userName,String password){
        return wtMemberMapper.loadUserByTelAndPwd(userName,password);
    }

    @Override
    public int updateOpenidByUserName(String userName,String openid){
        return wtMemberMapper.updateOpenidByUserName(userName,openid);
    }

    @Override
    public Result updateWtMemberMobile(WtMember wtMember) {
        int rt = wtMemberMapper.updateWtMemberByUserGuid(wtMember);
        if(rt > 0){
            return new Result(Result.SUCC,"修改手机号成功");
        }
        return new Result(Result.FAILURE,"失败");
    }

    @Override
    public Result updateWtMemberPwd(WtMember wtMember) {
        int rt = wtMemberMapper.updateWtMemberByUserGuid(wtMember);
        if(rt > 0){
            return new Result(Result.SUCC,"修改密码成功");
        }
        return new Result(Result.FAILURE,"失败");
    }

    @Override
    public Result updateWtMemberPwdByUserName(WtMember wtMember) {
        //int rt = wtMemberMapper.updateWtMemberByUserGuid(wtMember);
        int rt = wtMemberMapper.updateWtMemberByUserName(wtMember);
        if(rt > 0){
            return new Result(Result.SUCC,"修改密码成功");
        }
        return new Result(Result.FAILURE,"失败");
    }

    @Override
    public Result updateWtMemberInfo(WtMember wtMember) {
        int rt = wtMemberMapper.updateWtMemberByUserGuid(wtMember);
        if(rt > 0){
            return new Result(Result.SUCC,wtMember,"修改个人信息成功");
        }
        return new Result(Result.FAILURE,"失败");
    }

    @Override
    public Result saveWtMemner(WtMember wtMember) {
        int rt = wtMemberMapper.insertWtMemner(wtMember);
        if(rt > 0){
            return new Result(Result.SUCC,"网厅手机注册用户同步成功");
        }
        return new Result(Result.FAILURE,"失败");
    }

    @Override
    public Result saveWtMemberMange(WtMemberMange wtMemberMange) {
        int rt = wtMemberMapper.insertWtMemberMange(wtMemberMange);
        if(rt > 0){
            return new Result(Result.SUCC,"网厅手机注册用户同步成功");
        }
        return new Result(Result.FAILURE,"失败");
    }
}
